import React, { Component } from 'react'
function BeforEach(Com) {
    return class beforEach extends Component {
        componentDidMount() {
            this.login()
        }
        componentDidUpdate() {
            this.login()
        }
        login() {
            let path = this.props.location.pathname
            let arr = ['/login', '/register', '/sigIn']
            let flag = arr.includes(path)
            if (!flag) {
                let token = localStorage.getItem('token')
                if (!token) {
                    this.props.history.push('/login')
                }
            }
        }
        render() {
            return (
                <Com></Com>
            )
        }
    }
}
export default BeforEach


